home *** CD-ROM | disk | FTP | other *** search
/ Merciful 5 / Merciful - Disc 5.iso / software / p / pcqpascalv1.2d.lha / Examples2 / DeviceInfo / DeviceInfo.p
Text File  |  1997-05-06  |  3KB  |  99 lines

  1.  
  2. { *************************************************************************
  3.   **                                     **
  4.   **  DeviceInfo  -  Version 1.0,      (C)1992  by  Thomas Schmid     **
  5.   **                             Im Grenzacherhof 12 **
  6.   **   This programm is Public Domain,             CH- 4058 Basel     **
  7.   **   coded 18.02.1992 in PCQ-Pascal(1.2b).                             **
  8.   **   Gibt Info über angegebenes Device aus.                 **
  9.   **                         Usage :         **
  10.   **                            DeviceInfo Dfx:  **
  11.   **                                     **
  12.   *************************************************************************
  13. }
  14.  
  15. Program DeviceInfo;
  16.  
  17. {$I "include:libraries/dos.i"      }
  18. {$I "include:utils/parameters.i"   }
  19. {$I "include:exec/exec.i"          }
  20. {$I "include:utils/stringlib.i"    }
  21.  
  22. Const
  23.   MaxSize = 80;
  24.  
  25. Var
  26.   MyLock      : FileLock;
  27.   Inf          : InfoDataPtr;
  28.   Ok          : Boolean;
  29.   Myfile      : String;
  30.   S, S1          : String;
  31.   Size, Used, Bpb : Integer;
  32.  
  33. Procedure Cls;
  34.  
  35. Begin
  36.   WriteLn("\f   DeviceInfo V1.0 © 1992, by T.Schmid, Written in PCQ V1.2b\n");
  37.         { writeln("xxxxx \n") spart ein writeln !        -----^ }
  38. End;
  39.  
  40. Procedure AsdaLaVista(warum : String ; code : Integer);
  41.  
  42. Begin
  43.   If Inf   <> Nil Then FreeMem(Inf,SizeOf(InfoData));
  44.   If warum <> Nil Then WriteLn("",warum,"");
  45.   Exit(code);
  46. End;
  47.  
  48.  
  49. Begin
  50.   Myfile:=AllocString(80);
  51.   GetParam(1,Myfile);
  52.   If strlen(Myfile) = 0 Then AsdaLaVista(" DiskInfo V1.0, © 1992 T.Schmid - Usage : DiskInfo Dfx:",0);
  53.  
  54.   Inf:=InfoDataPtr( AllocMem( SizeOf(InfoData), MEMF_PUBLIC ) );
  55.   If Inf=Nil Then AsdaLaVista("Kein Speicher",5);
  56.  
  57.   s:=AllocString(20);        strcpy(S,"Beschreibbar");
  58.   s1:=AllocString(20);        strcpy(S1,"Dos");
  59.  
  60.   MyLock:=Lock(Myfile,ACCESS_READ);
  61.   If MyLock = Nil Then AsdaLaVista("Konnte Schlüssel nicht holen.",5);
  62.  
  63.   Ok:=Info(MyLock,Inf);
  64.   Unlock(MyLock);        { ------- Wichtig !! -------- }
  65.  
  66.   If Ok = FALSE Then AsdaLaVista("Konnte keine Info über Device holen",10);
  67.  
  68.   Bpb  := Inf^.id_BytesPerBlock;
  69.   Size := Inf^.id_NumBlocks     * Bpb DIV 1024;
  70.   Used := Inf^.id_NumBlocksUsed * Bpb DIV 1024;
  71.   Cls;
  72.  
  73.   WriteLn("   Info über Device        :  ", Myfile, "");
  74.   WriteLn("   Grösse                  :  ", Size, " KBytes  ","");
  75.   WriteLn("   Belegt                  :  ", Used, " KBytes  ","");
  76.   WriteLn("   Frei                    :  ", Size-Used, " KBytes  ","");
  77.   WriteLn("   Anzahl Bytes per Block  :  ", Inf^.id_BytesPerBlock, "");
  78.  
  79.   Case Inf^.id_DiskType of
  80.     ID_NO_DISK_PRESENT : strcpy(S1,"Keine Disk");
  81.     ID_UNREADABLE_DISK : strcpy(S1,"Disk nicht lesbar");
  82.     ID_NOT_REALLY_DOS  : strcpy(S1,"Keine Dos-Disk");
  83.     ID_KICKSTART_DISK  : strcpy(S1,"Kickstart-Disk");
  84.   End;
  85.  
  86.   WriteLn("   Disk Type               :  ",S1,"");
  87.   WriteLn("   Weiche Fehler           :  ",Inf^.id_NumSoftErrors,"");
  88.  
  89.   Case Inf^.id_DiskState of
  90.     ID_WRITE_PROTECTED : strcpy(S,"Schreibgeschützt");
  91.     ID_VALIDATING      : strcpy(S,"Wird Validiert");
  92.   End;
  93.   WriteLn("   Device Status           :  ",S,"");
  94.  
  95.   { wichtig : }
  96.   AsdaLaVista("\n  C U in next CF !\n",0);
  97.  
  98. End.
  99.